local TALKKEY = {
	[1] = "SAY",
	[2] = "YELL",
	[3] = "ORANGE",
	[4] = "ORANGE_YELL"
}

local TALKMODE ={
	[TALKKEY[1]] = 1,
	[TALKKEY[2]] = 3,
	[TALKKEY[3]] = 19,
	[TALKKEY[4]] = 20
}
function onSay( cid, words, param, channel)
	if( param == "" )then
		doPlayerSendTextMessage( cid, MESSAGE_STATUS_CONSOLE_BLUE, "You need to type the parameters. (player_name, words, speak_type:SAY/YELL/ORANGE/ORANGE_YELL)." )
		doSendMagicEffect( playerPos, CONST_ME_POFF )
		return false
	end

	
	local parameters = serializeParam( param )
	local playername = parameters[1]
	local words = parameters[2]
	local speak_type = parameters[3]

	if not ( playername ) then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Missing parameter: player_name.")
		return false
	end
	
	if not( words ) then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Missing parameter: words.")
		return false
	end
	
	if not ( speak_type ) then
		speak_type = TALKKEY[1]
	end
	
	if not TALKMODE[speak_type] then
		speak_type = TALKKEY[1]
	end

	local playerid = getCreatureByName(playername)
	if playerid == LUA_NULL or not isPlayer(playerid) then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player not found.")
		return false
	end
	
	--doCreatureSay
	doPlayerSay(playerid, words, TALKMODE[speak_type])
	
	doPlayerSendTextMessage( cid, MESSAGE_STATUS_CONSOLE_BLUE, "\"" ..words .. "\" was spoken (".. speak_type ..") by: " .. playername )
	
	return false
end
